﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.segments.data_type
{
    class CM_NDL
    {
        public CN Interpreter_Technician { get; set; }
        public TS Start_Date_time { get; set; }
        public TS End_Date_time { get; set; }
        public PL Location { get; set; }

        public int fill(string source, int temp)
        {
            int i, x = 0;
            for (i = temp; i < source.Length; i++)
            {
                if (source[i] == '^')
                    x++;
                else if (source[i] == '|')
                {
                    return i;
                }

                else if (x == 0)
                {
                    if (Interpreter_Technician == null)
                        Interpreter_Technician = new  CN();
                    i = Interpreter_Technician.fill(source, i);
                }
                else if (x == 1)
                {
                    if (Start_Date_time == null)
                        Start_Date_time = new TS();
                    i = Start_Date_time.fill(source, i);
                }
                else if (x == 2)
                {
                    if (End_Date_time == null)
                        End_Date_time = new  TS();
                    i = End_Date_time.fill(source, i);
                }
                else if (x == 3)
                {
                    if (Location == null)
                        Location = new  PL();
                    i = Location.fill(source, i);
                }              
            }
            return i;
        }
    }
}
